/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年7月2日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.MemberpermissionDao;
import org.scauinfo.fpos.service.MemberpermissionService;
import org.scauinfo.fpos.vo.Memberpermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 *
 */
@Service
public class MemberpermissionServiceImpl implements MemberpermissionService{
	@Autowired
	private MemberpermissionDao memberpermissionDao;
	
	@Override
	public void saveMemberpermission(Memberpermission memberpermission) {
		memberpermissionDao.save(memberpermission);
	}

	@Override
	public void updateMemberpermission(Memberpermission memberpermission) {
		memberpermissionDao.update(memberpermission);
	}
	@Override
	public void deleteMemberpermission(int id) {
		Memberpermission memberpermission = memberpermissionDao.get(id);
		memberpermission.setMembers(null);
		memberpermissionDao.delete(memberpermission);
	}

	@Override
	public List<Memberpermission> findAllMemberpermission(int page, int rows,
			String sort, String order) {
		return memberpermissionDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return memberpermissionDao.countAll();
	}

	@Override
	public boolean isExist(String memberpermissionId) {
		boolean flag = false;
		String hql = "from Memberpermission as p where p.memberpermissionId="
				+ memberpermissionId;
		if (memberpermissionDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public List<Memberpermission> findAllMemberpermission() {
		return memberpermissionDao.findAll();
	}

	@Override
	public Memberpermission get(Serializable id) {
		return memberpermissionDao.get(id);
	}

}
